<template>
  <div class="app-container">
    <!--???-->
    <div class="head-container">
      <!--??????????????????????? slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--????-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="????">
            <el-input v-model="form.eleName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="???">
            <el-input v-model="form.certificate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="????">
            ??????????? Select
          </el-form-item>
          <el-form-item label="??">
            <el-input v-model="form.message" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="????">
            ??????????? Select
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">??</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">??</el-button>
        </div>
      </el-dialog>
      <!--????-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="elementId" label="Id" />
        <el-table-column prop="eleName" label="????" />
        <el-table-column prop="certificate" label="???" />
        <el-table-column prop="certificateType" label="????" />
        <el-table-column prop="message" label="??" />
        <el-table-column prop="messageType" label="????" />
        <el-table-column prop="caseId" label="??id" />
        <el-table-column prop="isuse" label="????" />
        <el-table-column v-if="checkPer(['admin','caseElement:edit','caseElement:del'])" label="??" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--????-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudCaseElement from '@/api/caseElement'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { elementId: null, eleName: null, certificate: null, certificateType: null, message: null, messageType: null, caseId: null, isuse: null }
export default {
  name: 'CaseElement',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: 'api/case_element', url: 'api/caseElement', idField: 'elementId', sort: 'elementId,desc', crudMethod: { ...crudCaseElement }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'caseElement:add'],
        edit: ['admin', 'caseElement:edit'],
        del: ['admin', 'caseElement:del']
      },
      rules: {
      }    }
  },
  methods: {
    // ???????????????false ????????
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
